#include "tool.hpp"

void file1(char* a[]){
    cloud::FileTool ft(a[1]);

    std::cout << ft.getFileName() << std::endl;
    std::cout << ft.getSize() << std::endl;
    std::cout << ft.getMTime() << std::endl;
    std::cout << ft.getATime() << std::endl;
}

void file2(){
    std::string r = "../src/tool.hpp";
    std::string w = "test.txt";
    cloud::FileTool f1(r);
    cloud::FileTool f2(w);

    std::string rr ;
    f1.getAllContent(&rr);
    f2.setContent(rr);
    
}


void file3(){
    std::string r = "../src/log.hpp";
    std::string w = "test.txt";
    cloud::FileTool f1(r);

    std::string rr ;
    f1.getAllContent(&rr);
    std::string zipfile = "tool.lz";
    f1.zip(zipfile);
    
    cloud::FileTool f2(zipfile);
    f2.unzip(w);
}

void file4(){
    cloud::FileTool ft1("./CMakeFiles/3.26.5");

    std::cout << ft1.exists() << std::endl;

    cloud::FileTool ft2("./test4/");
    ft2.createDirectory();

    std::vector<std::string> a1;
    std::vector<std::string> a2;
    ft1.scanDirectory(&a1);
    for(auto & it : a1){
        std::cout << it << std::endl;
    }
    std::cout << std::endl;
    ft2.scanDirectory(&a2);
    for(auto & it : a2){
        std::cout << it << std::endl;
    }
}

void json(){
    const char *name = "焱";
    int age = 18;
    Json::Value root;
    root["名字"] = name;
    root["年龄"] = age;

    std::string content;
    cloud::jsonTool::serialize(root, &content);
    std::cout << content << std::endl;

    Json::Value deroot;
    cloud::jsonTool::deserialize(content, &deroot);
    std::cout << deroot["名字"].asString() << " " << deroot["年龄"].asInt64() << std::endl;
}

int main(int argc, char* argv[]){
    // file1(argv);

    // file4();

    json();

    return 0;
}